package com.ff.xyh.service.userfront.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.ff.xyh.common.entity.userfront.UserRestricted;
import com.ff.xyh.service.userfront.mapper.UserRestrictedMapper;
import com.ff.xyh.service.userfront.service.UserRestrictedService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

/**
 * <p>
 * 用户限制表 服务实现类
 * </p>
 *
 * @author ff
 * @since 2022-10-25
 */
@Service
public class UserRestrictedServiceImpl extends ServiceImpl<UserRestrictedMapper, UserRestricted> implements UserRestrictedService {

    @Override
    public UserRestricted getUserRestrictedByFrontUserId(String uid) {
        QueryWrapper wrapper = new QueryWrapper();
        wrapper.eq("user_id", uid);
        return baseMapper.selectOne(wrapper);
    }

    @Override
    public boolean updateUserRestricted(UserRestricted userRestricted) {
        if (getUserRestrictedByFrontUserId(userRestricted.getUserId()) == null)
            return false;
        return baseMapper.updateById(userRestricted) > 0;
    }
}
